// @ts-nocheck
import request from "../request";

// 用code换取token 示例
export function getSessionKeyOpenId(code: string) {
    return request.post("login/register-login", code);
}
export function decryptData(encryptedData: string) {
    return request.post("/api/user/decryptData", encryptedData);
}
export const loginToken = async (wxCode: string) => {
    return await request.post("login/register-login", {code: wxCode});
}
export const getAliUserId = async (code: string) => {
    return await request.post("user/getAliUserId", {code: code});
}
export const checkLogin = async () => {
    return await request.get("util/check-login");
}


export const getRoles = async () => {
    const {code, data, msg} = await request.get("login/roles");
    if (code !== 'A000') {
        console.log('调用失败getRoles：', data, msg)
        return []
    }
    return data
}

export const setNickNva = async (params: any) => {
    const {code, data, msg} = await request.post("login/nick-ava", params);
    if (code !== 'A000') {
        console.log('调用失败 setNickNva：', code, code != 'A000', data, msg)
        return code
    }
    return code
}
